package cn.cvs.service;

import cn.cvs.dao.SysUserMapper;
import cn.cvs.pojo.TSysUser;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysUserServiceImpl implements SysUserService{

    @Resource
    SysUserMapper sysUserMapper;

    @Override
    public Integer count() {
        return sysUserMapper.count();
    }

    @Override
    public List<TSysUser> getUserList(TSysUser param) {
        return sysUserMapper.getUserList(param);
    }

    @Override
    public TSysUser login(String account,String password) {

        TSysUser param = new TSysUser(account);

        TSysUser user = getUserList(param).get(0); //获取集合中的第一个值
        if (null!=user){
            if (account.equals(user.getAccount()) && password.equals(user.getPassword())){
                return user;
            }
        }
        return null;

    }

    @Override
    public Integer addUser(TSysUser user) {
        return sysUserMapper.addUser(user);
    }
}
